package utils

// ToCamelCase 字符串转换为驼峰命名
func ToCamelCase(str string) string {
	var camelCase string
	var isFirst bool
	for _, s := range str {
		if isFirst {
			camelCase += string(s)
		} else {
			camelCase += string(s)
		}
		if s == '_' {
			isFirst = true
		} else {
			isFirst = false
		}
	}
	return camelCase
}

// ToUnderlineCase 字符串转换为下划线命名
func ToUnderlineCase(str string) string {
	var underlineCase string
	for _, s := range str {
		if s >= 'A' && s <= 'Z' {
			underlineCase += "_"
			underlineCase += string(s + 32)
		} else {
			underlineCase += string(s)
		}
	}
	return underlineCase
}
